﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class D04_Mathf4 : MonoBehaviour
{
    public Transform cubeA, cubeB, sphere;

    [Range(0, 1)]
    public float f;

    public float duration = 2;//持续时间

    public AnimationCurve curve;

    //让sphere从cubeA到cubeb  根据f确定位置

    private void Update()
    {
        f += Time.deltaTime / duration;

        sphere.position = Vector3.Lerp(cubeA.position, cubeB.position, curve.Evaluate(f));
    }

    private void OnDisable()
    {
        f = 0;
    }
}